package ace.module.oauth2.server.core.impl.api.impl;

import ace.cmp.core.model.R;
import ace.module.common.api.annotation.ApiLocalPriority;
import ace.module.common.core.impl.api.impl.SdkApiImpl;
import ace.module.oauth2.server.api.Oauth2RegisteredClientApi;
import ace.module.oauth2.server.api.model.dto.Oauth2RegisteredClientDto;
import ace.module.oauth2.server.core.impl.dao.entity.Oauth2RegisteredClient;
import ace.module.oauth2.server.core.impl.manager.Oauth2RegisteredClientManager;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;


/**
 * oauth2 客户端 api implements.
 *
 * @author Caspar
 *
 */
@ApiLocalPriority
@AllArgsConstructor
@Component
public class Oauth2RegisteredClientApiImpl
    extends SdkApiImpl<Oauth2RegisteredClient, String, Oauth2RegisteredClientDto, Oauth2RegisteredClientManager>
    implements Oauth2RegisteredClientApi {

  private final Oauth2RegisteredClientManager oAuth2RegisteredClientManager;

  @Override
  public R<Oauth2RegisteredClientDto> getByClientId(String clientId) {
    Oauth2RegisteredClientDto oAuth2RegisteredClientDto =
        this.oAuth2RegisteredClientManager.getDtoByClientId(clientId);
    return R.ok(oAuth2RegisteredClientDto);
  }
}
